package com.heqiang.spring.service.common;

import com.heqiang.spring.beans.BeansException;
import com.heqiang.spring.beans.factory.config.BeanPostProcessor;
import com.heqiang.spring.service.TestService;

public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("testService".equals(beanName)) {
            TestService testService = (TestService) bean;
            testService.setLocation("上海");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}
